<template>
  <div class="root-wrap">
    <div class="home">
      Home
      <a class="tag-read" data-clipboard-text="我是可以复制的内容，请点击复制" target="_blank" @click="copyDocument">00000000000000000</a>
      <van-button type="primary">主要按钮</van-button>
    </div>
    <!-- footer -->
    <!-- <app-footer></app-footer> -->
  </div>

</template>
<script>
import AppHeader from "@/base/header/header";
import AppFooter from "@/base/footer/footer";
import Scroll from "@/base/scroll/scroll";
import { GET_HOMEDATA } from "@/api";
import { handleResponse } from "@/assets/js/common";
import Clipboard from 'clipboard';
export default {
  data() {
    return {
      homeData: {
        anno: {},
        slideList: [],
        quesList: [],
      },
    };
  },
  components: {
    AppFooter,
    Scroll,
  },
  created() {
    // this._reqHomeData();
  },
  filters: {
    descFilter(val) {
      if (val) {
        return val;
      } else {
        return "这个家伙没有留下问题描述....";
      }
    },
  },
  methods: {
    handleQuesClick(id) {
      this.$router.push(`/ask/details?id=${id}`);
    },
    _reqHomeData() {
      GET_HOMEDATA().then((res) => {
        handleResponse(res, () => {
          this.homeData = res.data;
        });
      });
    },
    copyDocument() {
      var clipboard = new Clipboard('.tag-read')
      clipboard.on('success', e => {
        console.log('复制成功')
        //  释放内存
        clipboard.destroy()
      })
      clipboard.on('error', e =>{
        // 不支持复制
        console.log('该浏览器不支持复制')
        // 释放内存
        clipboard.destroy()
      })
    }
  },
};
</script>
<style lang="less" scoped>
.home {
  position: fixed;
  top: 0;
  bottom: 50px;
  width: 100%;
  color: red;

  a {
    color: red;
  }
}
</style>


